package logic

import (
	"context"
	"house_srv/model/mysql"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseDetailLogic {
	return &HouseDetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *HouseDetailLogic) HouseDetail(in *house.HouseDetailRequest) (*house.HouseDetailResponse, error) {
	// todo: add your logic here and delete this line
	var houses mysql.House
	mysql.DB.Where("id=?", in.Id).Limit(1).Find(&houses)
	return &house.HouseDetailResponse{
		Name:    houses.Name,
		Area:    float32(houses.Area),
		Price:   float32(houses.Price),
		Address: houses.Address,
	}, nil
}
